<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>08-排他思想(算法)</title>
    <style>
        div{
            display: flex;
            justify-content: center;
        }
        p{
             width: 100px;
            height: 100px;   
            background-color: skyblue;
            border-radius:50%;
            text-align: center;
            line-height: 100px;
            font-size: 24px;
            color: white;
            margin:50px 15px;
        }
    </style>
</head>
<body>
        <div>
            <p>1</p>
            <p>2</p>
            <p>3</p>
            <p>4</p>
            <p>5</p>
        </div>
    <script>
        let p = document.querySelectorAll('p');
        // console.log(p);
        for(let i = 0; i<p.length; i++){
            p[i].addEventListener('click',function(){
                for(let j = 0; j <p.length;j++){
                    p[j].style.background = '';
                }
                // p[i].style.color = 'red';
                this.style.color = 'black';
                // this.style.background = 'orange';
                this.style.backgroundImage = 'linear-gradient(270deg,red,blue)';
            });
            
        }

    </script>
</body>
</html>